package cn.edu.scau.cmi.dengzejun.chapter09;

import java.text.*;

public class Example9_18 {
	public static void main(String args[]) {
		double number = 98765.123456;
		System.out.println("the "+number+" format is 6 integer at least and 3 point at most");
		DecimalFormat df = new DecimalFormat("000000.000");
		String result = df.format(number);
		System.out.println(result);
		number = 12345678.987654;
		System.out.printf("%f has 2 integer at least and 4 point at most \n", number);
		df.applyPattern("#,# #,#00.0000$");
		result = df.format(number);
		System.out.println(result);
		number = 0.9876796;
		System.out.println("from "+number+" to percentage and permillage");
		df.applyPattern("0.0000%");
		result = df.format(number);
		System.out.println(result);
		df.applyPattern("0.0000\u2030");
		result = df.format(number);
		System.out.println(result);
		String money = "9,576,769,345$";
		System.out.println("transform it to number");
		df.applyPattern("#,# #,# #0.000");
		try {
			Number num = df.parse(money);
			System.out.println(num.doubleValue());
		}catch(Exception exp) {
			
		}
		return ;
	}
}
